home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
examples
/
chap05
/
ColorTester.java
< prev
next >
Wrap
Text File
|
1996-10-08
|
2KB
|
56 lines
// ColorTester.java
import vrml.*;
import vrml.node.*;
import vrml.field.*;
public class ColorTester extends Script{
ColorPanel panel;
SFFloat a_field, s_field, t_field;
SFColor dc_field, ec_field, sc_field;
public void initialize(){
// get the reference to the target node.
Node target = (Node)((SFNode)getField("target")).getValue();
panel = new ColorPanel(this); // start the panel.
// get the references to exposed fields, event-in/outs.
a_field = (SFFloat)target.getExposedField("ambientIntensity");
dc_field = (SFColor)target.getExposedField("diffuseColor");
ec_field = (SFColor)target.getExposedField("emissiveColor");
s_field = (SFFloat)target.getExposedField("shininess");
sc_field = (SFColor)target.getExposedField("specularColor");
t_field = (SFFloat)target.getExposedField("transparency");
}
public void processEvent(Event ev){
if(ev.getName().equals("entered")){
ConstSFBool v = (ConstSFBool)ev.getValue();
if(v.getValue()){ panel.map(); }
else { panel.hide(); }
}
}
public void shutdown(){ panel.dispose(); }
public float get_ambientIntensity(){ return(a_field.getValue()); }
public void set_ambientIntensity(float val){ a_field.setValue(val); }
public void get_diffuseColor(float[] rgb){ dc_field.getValue(rgb); }
public void set_diffuseColor(float[] val){ dc_field.setValue(val); }
public void get_emissiveColor(float[] rgb){ ec_field.getValue(rgb); }
public void set_emissiveColor(float[] val){ ec_field.setValue(val); }
public float get_shininess(){ return(s_field.getValue()); }
public void set_shininess(float val){ s_field.setValue(val); }
public void get_specularColor(float[] rgb){ sc_field.getValue(rgb); }
public void set_specularColor(float[] val){ sc_field.setValue(val); }
public float get_transparency(){ return(t_field.getValue()); }
public void set_transparency(float val){ t_field.setValue(val); }
}